package com.xxx.blog.controller;

import com.xxx.base.utils.R;
import com.xxx.blog.domain.Param;

import com.xxx.blog.service.IParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController//@rc
@RequestMapping("/param")
@Api(tags = "系统参数接口")
public class ParamController {
    @Autowired
    private IParamService paramService;

    @GetMapping
    @ApiOperation(value = "获取参数map")
    public R<Map<String,String>> paramMap() {
        List<Param> all = paramService.findAll();
        //HashMap<String,String> map = new HashMap<>();
        //for (Param param : all) {
        //    map.put(param.getParam_key(), param.getParam_value());
        //}
        Map<String,String>map = all.stream().collect(Collectors.toMap(Param::getParamKey,Param::getParamValue));
        return R.ok(map);//alt enter生成返回值
    }


}
